﻿Imports Mysoft.Map.Data
Partial Public Class SalesBudget_Edit_Grid
    Inherits Mysoft.Map.Application.Security.AppPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            '绑定数据
            Data_Bind()
        End If
    End Sub

    Private Sub Data_Bind()
        Dim strSBGUID As String = Request.QueryString("SBGUID")
        Dim strSQL As String
        If strSBGUID = "" Then
            strSQL = "SELECT '' as rowid,'' AS SBDtlGUID,'' AS SBGUID, pb.BProductTypeName,pb.BuildProductTypeGUID,0 AS Rooms ," & _
                     "0 AS BldArea, 0 AS Amount, 0 AS Price ,0 AS JHHKAmount " & _
                     " FROM p_BuildProductType pb LEFT JOIN s_SalesBudgetDetail ss ON pb.BuildProductTypeGUID=ss.BuildProductTypeGUID WHERE pb.Level=2 GROUP BY pb.BuildProductTypeGUID,pb.BProductTypeName,BProductTypeCode  ORDER BY BProductTypeCode "
        Else
            strSQL = "SELECT '' as rowid, pb.BProductTypeName,ss.SBDtlGUID,ss.SBGUID,pb.BuildProductTypeGUID,isnull(ss.Rooms,0) AS Rooms ," & _
                     "isnull(ss.BldArea,0) AS BldArea, isNull(ss.Amount,0) AS Amount, isnull(ss.Price,0) AS Price ,isnull(ss.JHHKAmount,0) AS JHHKAmount " & _
                     " FROM p_BuildProductType pb LEFT JOIN s_SalesBudgetDetail ss ON pb.BuildProductTypeGUID=ss.BuildProductTypeGUID  And SBGUID='" & strSBGUID & "' WHERE pb.Level=2 ORDER BY BProductTypeCode"
        End If
        Repeater1.BindMode = 0                                          '绑定模式：0 -- SQL 语句绑定，1 -- DataTable 绑定
        Repeater1.ConnectionString = MyDB.GetSqlConnectionString        '设置连接字符串
        Repeater1.SQL = strSQL                                          '设置查询语句
        Repeater1.DataBind()                                            '绑定数据
    End Sub
End Class